home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / ace / c / window.c < prev   
Encoding:
C/C++ Source or Header  |  1998-10-04  |  4.1 KB  |  181 lines

  1. /* << ACE >>
  2.  
  3.    -- Amiga BASIC Compiler --
  4.  
  5.    ** Parser: window functions **
  6.    ** Copyright (C) 1998 David Benn
  7.    ** 
  8.    ** This program is free software; you can redistribute it and/or
  9.    ** modify it under the terms of the GNU General Public License
  10.    ** as published by the Free Software Foundation; either version 2
  11.    ** of the License, or (at your option) any later version.
  12.    **
  13.    ** This program is distributed in the hope that it will be useful,
  14.    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    ** GNU General Public License for more details.
  17.    **
  18.    ** You should have received a copy of the GNU General Public License
  19.    ** along with this program; if not, write to the Free Software
  20.    ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  21.  
  22.    Author: David J Benn
  23.      Date: 26th October-30th November, 1st-13th December 1991,
  24.        14th,20th-27th January 1992, 
  25.            2nd-17th, 21st-29th February 1992, 
  26.        1st,13th,14th,22nd,23rd March 1992,
  27.        21st,22nd April 1992,
  28.        2nd,3rd,11th,15th,16th May 1992,
  29.        7th,8th,9th,11th,13th,14th,28th,29th,30th June 1992,
  30.        2nd-8th,14th-19th,26th-29th July 1992,
  31.        1st-3rd,7th,8th,9th August 1992,
  32.        6th,7th December 1992,
  33.        24th,26th October 1993,
  34.        15th November 1993,
  35.        30th April 1994
  36. */
  37.  
  38. #include "acedef.h"
  39.  
  40. /* externals */
  41. extern    int    sym;
  42. extern    int    lastsym;
  43.  
  44. /* functions */
  45. void window()
  46. {
  47. int wtype;
  48.  
  49.  /* WINDOW wdw-id[,title],rectangle[,type][,screen-id] 
  50.     WINDOW CLOSE wdw-id
  51.     WINDOW OUTPUT wdw-id 
  52.     WINDOW ON | OFF | STOP
  53. */
  54.  
  55.  insymbol();
  56.  
  57.  if (sym == onsym || sym == offsym || sym == stopsym)
  58.     change_event_trapping_status(lastsym);
  59.  else
  60.  if (sym == closesym) wdwclose();
  61.  else
  62.  if (sym == outputsym) wdwoutput();
  63.  else
  64.  {
  65.   /* open a window */
  66.   if (make_integer(expr()) == shorttype) make_long();      /* Wdw-id */
  67.   if (sym != comma) _error(16);
  68.   else
  69.   {
  70.    insymbol();
  71.    if (sym != comma)
  72.    {
  73.     wtype=expr();
  74.     if (wtype != stringtype) _error(4); /* type mismatch */
  75.    }
  76.    else
  77.     gen("move.l","#0","-(sp)");    /* NULL */
  78.    
  79.    if (sym != comma) _error(16);
  80.    else
  81.    {
  82.     insymbol();
  83.     if (sym != lparen) _error(14);
  84.     else
  85.     {
  86.      insymbol();
  87.      if (make_integer(expr()) == shorttype) make_long();  /* x1 */
  88.      if (sym != comma) _error(16);
  89.      else
  90.      {
  91.       insymbol();
  92.       if (make_integer(expr()) == shorttype) make_long();  /* y1 */
  93.       if (sym != rparen) _error(9);
  94.       else
  95.       {
  96.        insymbol();
  97.        if (sym != minus) _error(21);
  98.        else
  99.        {
  100.         insymbol();
  101.         if (sym != lparen) _error(14);
  102.         else
  103.         {
  104.          insymbol(); 
  105.          if (make_integer(expr()) == shorttype) make_long();  /* x2 */
  106.          if (sym != comma) _error(16);
  107.          else
  108.          {
  109.           insymbol();
  110.           if (make_integer(expr()) == shorttype) make_long();  /* y2 */
  111.           if (sym != rparen) _error(9);
  112.          }
  113.  
  114.      insymbol();
  115.      
  116.      /* optional window type */
  117.      if (sym == comma)
  118.      {
  119.         insymbol();
  120.         if (sym != comma)
  121.         {
  122.             if (make_integer(expr()) == shorttype) 
  123.                   make_long();  /* type */
  124.         }
  125.         else
  126.             gen("move.l","#-1","-(sp)");
  127.      }
  128.      else
  129.         gen("move.l","#-1","-(sp)");
  130.  
  131.      /* optional screen-id */
  132.      if (sym == comma)
  133.      {
  134.         insymbol();
  135.         if (sym != comma)
  136.         {
  137.             if (make_integer(expr()) == shorttype) 
  138.                   make_long();  /* scrn-id */
  139.         }
  140.         else
  141.             gen("move.l","#0","-(sp)");
  142.      }
  143.      else
  144.         gen("move.l","#0","-(sp)");        
  145.      
  146.      /* call open-window routine */
  147.      gen("jsr","_OpenWdw","  ");
  148.      gen("add.l","#32","sp");
  149.      enter_XREF("_OpenWdw");
  150.      enter_XREF("_IntuitionBase");
  151.      enter_XREF("_GfxBase");
  152.         }
  153.        }
  154.       }
  155.      }
  156.     }    
  157.    }
  158.   }
  159.  }
  160. }
  161.  
  162. void wdwclose()
  163. {
  164.  insymbol();
  165.  if (make_integer(expr()) == shorttype) make_long();    /* Wdw-id */
  166.  gen("jsr","_CloseWdw","  ");
  167.  gen("addq","#4","sp");
  168.  enter_XREF("_CloseWdw");
  169.  enter_XREF("_IntuitionBase");
  170. }
  171.  
  172. void wdwoutput()
  173. {
  174.  insymbol();
  175.  if (make_integer(expr()) == shorttype) make_long();    /* Wdw-id */
  176.  gen("jsr","_ChangeOutputWdw","  ");
  177.  gen("addq","#4","sp");
  178.  enter_XREF("_ChangeOutputWdw");
  179.  enter_XREF("_IntuitionBase");
  180. }
  181.